# -*- coding: utf-8 -*-
import json
from flask import jsonify
from core import tools

params_error = '10010'
passno       = '10011'
phoneno      = '10012'
tokenno      = '10013'
userno       = '10020'
devno        = '10021'
saferegionno = '10022'
relateno     = '10023'
familyno     = '10024'
jsonno       = '10030'
serverno     = '10031'
hasconflict  = '10040'
needadmin    = '10041'
hasown       = '10042'
hasadmin     = '10043'
disadmin     = '10044'
starno       = '10050'
modifyno     = '10051'
silnummax    = '10060'
silexist     = '10061'
monitorno    = '10070'
intervalno   = '10071'
emailconflict= '10080'
emailno      = '10081'
languageno   = '10082'
notesendno   = '10083'
locateno     = '10090'
locatelimit  = '10091'
offline      = '10100'
timeout      = '10101'
ok           = '20000'
userexist    = '20001'
userupdate   = '20002'
needauth     = '20003'
needbabyauth = '20004'


json.dumps = tools.dumps
dumps = json.dumps
loads = json.loads

def succed(msg='',data=None):
    if data is not None:
        return jsonify(status=200,msg=msg,data=data)
    else:
        return jsonify(status=200,msg=msg)

def failed(msg='',data=None):
    if data is not None:
        return jsonify(status=300,msg=msg,data=data)
    else:
        return jsonify(status=300,msg=msg)


if __name__ == '__main__':
    import datetime
    import decimal
    test = datetime.datetime(2014,8,26,14,9,30)
    print(json.dumps(test))
    test = decimal.Decimal(3,1415926)
    print(json.dumps(test))

